#ifndef WORLDMODEL_H
#define WORLDMODEL_H

#include "IWorldModel.h"

#include "InputAction.h"
#include "Vector2i.h"
#include <vector>
using std::vector;

//!Class representing the world of the game.
class CWorldModel: public IWorldModel
{
private:
	//!Store the entities
	vector<CWorldEntity*> m_vectorEntity;

	//!Index of the player entity
	int m_indexPlayer;

	//!Indicate if we have to quit the game
	bool m_quitGame;

	//!Indicate if the game is on pause.
	bool m_pauseGame;

	//!Index of the texture to display when the game is on pause.
	int m_idTexturePauseScreen;

public:
	//!Constructor
	CWorldModel();

	//!Destructor
	~CWorldModel();

	//!Udpate all the entities.
	void doUpdate(void);

	//!Render all the entities
	void doRender(void);

	//!Create an entity player
	/*!
	\param startPosition The position where the player start.
	\param speed The speed of the player.
	\param idAnimWalkRight The animation's index of the player walking to the right.
	\param idAnimWalkLeft The animation's index of the player walking to the left.
	\param indexAnimIdleRight The animation's index of the player idling to the right.
	\param indexAnimIdleLeft The animation's index of the player idling to the left.
	\param indexAnimJumpRight The animation's index of the player jumping to the right.
	\param indexAnimJumpLeft The animation's index of the player jumping to the left.
	\param indexAnimAttackRight The animation's index of the player attacking to the right.
	\param indexAnimAttackLeft The animation's index of the player attacking to the left.
	\param healthPoint The health point of the player.
	*/
	void createEntityPlayer(const CVector2i& startPosition, int speed, int idAnimWalkRight,
		int idAnimWalkLeft, int indexAnimIdleRight, int indexAnimIdleLeft, int indexAnimJumpRight, int indexAnimJumpLeft,
		int indexAnimAttackRight, int indexAnimAttackLeft, int healthPoint);

	//!Create an decor object
	/*!
	\param indexGfx Index of the texture representing the object
	\param startPosition Start position of the object.
	*/
	void createEntityDecor(int indexGfx, const CVector2i& startPosition);

	//!Create a projectile entity
	/*!
	\param indexTexture Index of texture representing the projectile
	\param indexSprite Index of the sprite in the texture
	\param position Position of the projectile
	\param speed Speed of the projectile
	\return A pointer to the entity projectile created.
	*/
	CEntityProjectile* createEntityProjectile(int indexTexture, int indexSprite, const CVector2i& position, int speed);

	//!Create an enemy entity
	/*!
	\param initialPosition Start position of the enemy
	\param range The range of displacement of the enemy
	\param animWalkLeft The index of the animation of the enemy walking to the left.
	\param animWalkRight The index of the animation of the enemy walking to the right.
	\param hp The health point of the enemy
	\param damagePoint The damage caused when an other entity collide with this entity.
	\param speed The speed of the enemy.
	\return A pointer to the entity created.
	*/
	CEntityEnemy* createEntityEnemy(const CVector2i& initialPosition, int range, int animWalkLeft, 
		int animWalkRight, int hp, int damagePoint, int speed);

	//!Create an explosion entity
	/*!
	\param indexAnimation Index of the animation representing the explosion
	\param position Position of the explosion
	\param sound Index of the sound to play during the explosion.
	\return A pointer to the explosion entity created.
	*/
	CEntityExplosion* createEntityExplosion(int indexAnimation, const CVector2i& position, int sound);


	//!Add a action to perform
	/*!
	\param newAction The action to perform.
	*/
	void addAction(eAction newAction);

	//!Fill the quad tree with all the entity created and contained in the vector of entity. 
	void fillQuadTree(void);

	//!Check if entity is colliding.
	/*!
	\return A pointer to the entity that entity collides with. If there is no collision, it returns 0.
	*/
	CWorldEntity* checkCollision(CWorldEntity* entity);

	//!Quit the game.
	bool quitGame(void);

	//!Scroll all the world so all the entities
	/*!
	\param scroll The translation vector.
	*/
	void scrollWorld(const CVector2i& scroll);

	//!Get the helath of the player
	/*!
	\return The health of the player.
	*/
	int getHealthPlayer(void)const;

	//!Set the texture index of the pause screen
	/*!
	\param idTexturePauseScreen The index of the texture.
	*/
	void setPauseScreen(int idTexturePauseScreen);

};

#endif
